/*=====================================================================================

 news_sni.do: 
	
   Analyzes the PFD's dependency on oil revenue	
   

		Lorenz Kueng, December 2017

=======================================================================================*/

cap log close PFD_04
log using "$homedir/log-files/PFD_04_$date.log", replace name(PFD_04)					


import excel "$homedir/data/APF_Data.xlsx", sheet("Oil Revenue") cellrange(A6:I46) firstrow clear
	
	generate MinearToFund = StateMineralRevenues/TotalFundValue*100
	lab var  MinearToFund "mineral revenues / total fund value  (in %)"
	
	tsset FiscalYear
		
	cap drop mlab 
	generate mlab = string(MinearToFund,"%2.1f")
	forvalues y = 1978(2)2016 {
		replace mlab = "" if FiscalYear==`y'
	}

	twoway connected MinearToFund FiscalYear, lp(solid) lc(black) connect(line) mc(black) mlabel(mlab) mlabc(black) mlabposition(12) || ///
		, xtitle("fiscal year") xlabel(1980(5)2015) ytitle("") ylabel(, angle(0)) /// 
		  legend( on ) graphregion(color(white)) legend(order(1) col(1) ring(0) pos(12) region(lwidth(none)))

		local file "${homedir}/results/figures/APFC_FracOil"
		graph export "`file'.eps", replace
		cap rm       "`file'.pdf"
		!epstopdf    "`file'.eps"
		graph export "`file'.tif", replace
	

log close PFD_04
